
function GetXmlHttpObject()
{
    var xmlHttp1=null;
    try{
        // Firefox, Opera 8.0+, Safari
        xmlHttp1=new XMLHttpRequest();
    }catch (e){
        //Internet Explorer
        try{
            xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp1;
}

function getProductList(selectCategory){
    
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request");
        return;
    }
    var selectedCategory = selectCategory.options[selectCategory.selectedIndex].value;
    
    var url="product.do?action=getProductByCategory";
    url=url+"&categoryId="+selectedCategory;

    xmlHttp.onreadystatechange=selectProduct;
    xmlHttp.open("POST",url,true);
    xmlHttp.send(null);
}

function selectProduct(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        var dataProduct = xmlHttp.responseText;
        if(dataProduct.length > 0){
            $('#product').html(dataProduct);
        }      
    }
}

